package cn.kongwg.demo03;

import java.util.concurrent.*;

/**
 * @author kongwg
 * @create 2021-05-27 15:51
 */
public class ExecuterDemo {
    public static void main(String[] args) {
        ThreadPoolExecutor executor = new ThreadPoolExecutor(
                2,
                5,
                1,
                TimeUnit.SECONDS,
                new LinkedBlockingQueue(3),
                Executors.defaultThreadFactory(),
                new ThreadPoolExecutor.AbortPolicy()
        );


        try {
            for (int i = 0; i < 19; i++) {
                executor.execute(() -> {
                    System.out.println(Thread.currentThread().getName()+"\t 开始工作");
                });

            }
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            executor.shutdown();
        }

    }
}
